<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title><?php echo ($webData["title"]); ?></title>
		<link rel="shortcut icon" href=" __PUBLIC__/Imgs/bitbug_favicon.ico" />
		<link href="__PUBLIC__/Home/Css/header.css" rel="stylesheet" type="text/css" />	
	</head>
	<body>
		<div id="header_top">
<!--			<img src="__ROOT__/Uploads/thumb/th_<?php echo ($webData["logo"]); ?>" style="float:left;" width="150">-->
			<img src="__ROOT__/Uploads/thumb/st.jpg" style="float:left;" width="150">
			<form action="__APP__/Index/searchFoods" method="post">
				<input type="text" id="header_seach" name="fname">
				<input type="submit" id="header_sub" value="搜索">
			</form>

			<ul id="header_ul">
				<li><a href="__APP__/Index/index/">首页</a></li>
				<li><a href="__APP__/Bclass/index/">菜谱分类</a></li>
			</ul>
			<div id="header_login">
			<?php if(empty($_SESSION['uname'])): ?><span>
						<a href="__APP__/Login/login/" target="_blank">
							登录
						</a>
					</span>
					<span>
						<a href="__APP__/Login/reg/" target="_blank">
							注册
						</a>
					</span>
			<?php else: ?>				
				<span>
					<a href="">
					<?php echo (session('uname')); ?>
					</a>
				</span>
				<span>
					<a href="__APP__/Ucenter/index/pass">
					个人中心
					</a>
				</span>
				<span>
					<a href="__APP__/Carts/showCarts/">
					购物车
					</a>
				</span>
				<?php if(!empty($_SESSION['uMsg'])): ?><span>
					<a href="__APP__/Posts/details/form_number/<?php echo (session('uMsg')); ?>" class="clearMsg">
					新订单
					</a>
				</span><?php endif; ?>
				<span style="font-size:14px;">
					<a href="__APP__/Public/loginout/">
					退出
					</a>
				</span><?php endif; ?>
			</div>
		</div>
		<div style="clear:both;height:30px;"></div>
	</body>
</html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>reg index</title>
	<link href="__PUBLIC__/Home/Css/reg.css" rel="stylesheet" type="text/css" />
	<script src="__PUBLIC__/Js/jquery-1.8.3.js"></script>
	
	<script type="text/javascript">
		$(function(){
			$('#regSubmit').submit(function(){
				var email = $('#regSubmit .email').val();
				var userpwd = $('#regSubmit .userpwd').val();
				var ruserpwd = $('#regSubmit .ruserpwd').val();
				var username = $('#regSubmit .username').val();

				if('' == email || ('' != email && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(email))){
					alert('邮箱不正确!');
					return false;
				}

				if('' == userpwd || userpwd != ruserpwd || ('' != userpwd && !/^[a-z0-9_-]{6,18}$/.test(userpwd))){
					alert('密码不正确!');
					return false;
				}

				if('' == username || ('' != username && !/^[a-zA-Z0-9_-]{3,16}$/.test(username))){
					alert('用户名不正确!');
					return false;
				}				
			});

			$('#regSubmit .email').blur(function(){
				var email = $('#regSubmit .email').val();
				$(this).parent().next().children().remove();

				if('' == email || ('' != email && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(email))){
					
					$(this).parent().next().append('<font color="red">邮箱不正确</font>');
					return false;
				}
				
				var $parent = $(this).parent().next();
				$.post('__APP__/Login/yzemail/',{email:email},function(jdata){

					 	// var data = eval("("+jdata+")");//AJAX返回传来的值是JSON形式的数据，用eval转码
					 	var data = jdata;
					 	var exist = '';

					 	if(data.data=="exist"){
						     exist = '<font color="red">该邮箱已被注册.</font>';
						     	
						}else{
							exist = '<font color="green">该邮箱可用.</font>';
						}

						$parent.append(exist);
				});  

			});

			$('#regSubmit .userpwd').blur(function(){
				var userpwd = $('#regSubmit .userpwd').val();
				$(this).parent().next().children().remove();

				if('' == userpwd || ('' != userpwd && !/^[a-z0-9_-]{6,18}$/.test(userpwd))){
					
					$(this).parent().next().append('<font color="red">密码6-18位</font>');
				}else{
					$(this).parent().next().append('<font color="green">密码格式正确</font>');
				}
			});

			$('#regSubmit .ruserpwd').blur(function(){
				var userpwd = $('#regSubmit .userpwd').val();
				var ruserpwd = $('#regSubmit .ruserpwd').val();
				$(this).parent().next().children().remove();

				if('' == userpwd || userpwd != ruserpwd || ('' != userpwd && !/^[a-z0-9_-]{6,18}$/.test(userpwd))){
					
					$(this).parent().next().append('<font color="red">两次密码不一致</font>');
				}else{
					$(this).parent().next().append('<font color="green">密码输入正确</font>');
				}
			});

			$('#regSubmit .username').blur(function(){
				var username = $('#regSubmit .username').val();
				$(this).parent().next().children().remove();

				if('' == username || ('' != username && !/^[a-zA-Z0-9_-]{3,16}$/.test(username))){
					
					$(this).parent().next().append('<font color="red">昵称不正确</font>');
					return false;
				}

				var $parent = $(this).parent().next();
				//AJAX连接数据库判断用户是否存在				
				 $.post('__APP__/Login/yzuser/',{username:username},function(data){
				 	// var data = eval("("+jdata+")");//AJAX返回传来的值是JSON形式的数据，用eval转码
				 	
				 	var exist;

				 	if(data.data=="exist"){
					     exist = '<font color="red">该用户名已存在.</font>';
					}else{
					     exist = '<font color="green">该用户名可用.</font>';
					}

					$parent.append(exist);
				});
			});			
		});
	</script>
</head>
<body>
	<div id="reg_wrap">
		<h2>注册一个新的帐号</h2>
		<div id="reg_content">
			<form action="__APP__/Login/checkReg/" method="post" id="regSubmit">
				<table  cellpadding="0" cellspacing="0" border="0" style="margin-left:150px;">
					<tr>
						<td width="100" align="center">邮　　箱
						<font color="red">*</font>
						</td>
						<td width="200">
						<input type="text" name="email" class="email input500"></td>
						<td style="text-indent:1em;"></td>
					</tr>
					<tr>
						<td align="center">
						密　　码
						<font color="red">*</font>
						</td>
						<td><input type="password" name="userpwd" class="userpwd input500"></td>
						<td style="text-indent:1em;"></td>
					</tr>
					<tr>
						<td align="center">
						确认密码
						<font color="red">*</font>
						</td>
						<td><input type="password" name="ruserpwd" class="ruserpwd input500"></td>
						<td style="text-indent:1em;"></td>
					</tr>
					<tr>
						<td align="center">
						昵　　称
						<font color="red">*</font>
						</td>
						<td><input type="text" name="username" class="username input500"></td>
						<td style="text-indent:1em;">
							
						</td>
					</tr>
					<tr>
						<td align="center">
						验证码
						</td>
						<td><input type="text" name="verify" class=" input500" style="width:100px;"><img src='__APP__/Login/verify/' onClick="changeImg(this)"/></td>
						<td style="text-indent:1em;">
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td>
							<button type="submit" class="butAdd">
							注册
							</button>
						</td>
					</tr>
				</table>
			</form>	
		</div>		
	</div>
</body>
</html>
<script>
			function changeImg(obj){
				obj.src = '__APP__/Login/verify/'+Math.random();
			}

		</script>